package logic

import (
	"context"
	"ewaimai/waimairpc/models"

	"ewaimai/waimairpc/internal/svc"
	"ewaimai/waimairpc/waimairpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type PeisongAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPeisongAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PeisongAddLogic {
	return &PeisongAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PeisongAddLogic) PeisongAdd(in *waimairpc.PeisongAddRequest) (*waimairpc.PeisongAddResponse, error) {
	// todo: add your logic here and delete this line
	var p models.Peisong
	p.Qishou = in.Qishou
	p.Address = in.Address
	p.OrderNo = in.OrderNo
	p.Status = 1
	if err := p.CreatePeisong(); err != nil {
		logx.Errorf("配送成功")
	}
	return &waimairpc.PeisongAddResponse{
		Id: int64(p.ID),
	}, nil
}
